-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ext/standard: Deprecate $http_response_header #19464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ext/standard/tests/http/http_response_header_deprecated_bypass.phpt
Outdated
Show resolved
Hide resolved
Zend/zend_compile.c
Outdated
@@ -339,6 +339,7 @@ void zend_oparray_context_begin(zend_oparray_context *prev_context, zend_op_arra | |||
CG(context).try_catch_offset = -1; | |||
CG(context).current_brk_cont = -1; | |||
CG(context).last_brk_cont = 0; | |||
CG(has_assigned_to_http_response_header) = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, doesn't this need to be on the op array context instead? Otherwise we only warn once per compilation instead of once per file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added tests and it seems to work as I expect it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah okay I see I actually think I wanted to say "once per op_array", but if that's the intention that's fine I guess?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it seems to be once per op_array 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check this again tomorrow when I'm more awake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you reset the variable when a new op context starts, but they can be nested. So the following emits 2 deprecations even though it should only emit 1 (artificial example I know, but a simple one):
<?php
function foo() {
$http_response_header = "foo";
function nested() {
echo $http_response_header;
}
echo $http_response_header;
}
You can remove the code from "nested" and it will still emit a deprecation that should not be happening.
d72a12a
to
3b716b4
Compare
ext/standard/tests/http/http_response_header_deprecated_bypass.phpt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RM approval: 👍
Zend/zend_compile.c
Outdated
@@ -339,6 +339,7 @@ void zend_oparray_context_begin(zend_oparray_context *prev_context, zend_op_arra | |||
CG(context).try_catch_offset = -1; | |||
CG(context).current_brk_cont = -1; | |||
CG(context).last_brk_cont = 0; | |||
CG(has_assigned_to_http_response_header) = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you reset the variable when a new op context starts, but they can be nested. So the following emits 2 deprecations even though it should only emit 1 (artificial example I know, but a simple one):
<?php
function foo() {
$http_response_header = "foo";
function nested() {
echo $http_response_header;
}
echo $http_response_header;
}
You can remove the code from "nested" and it will still emit a deprecation that should not be happening.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_http_response_header_predefined_variable